package com.ay.weixin.fdc.boss.project.db;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import lizar.db.ibatis.Dao;

import com.ay.weixin.fdc.boss.project.domain.FDCProjectGrah;

public class IbatisProjectGrahDao extends Dao{
	
	public void insert(FDCProjectGrah grah) throws SQLException{
		this.sqlMapper.insert("fdc_project_grah.insert",grah);
	}
	
	public void update(FDCProjectGrah project) throws SQLException{
		this.sqlMapper.update("fdc_project_grah.update",project);
	}
	
	public boolean exists(long id) throws SQLException{
		Object obj=this.sqlMapper.queryForObject("fdc_project_grah.exists",id);
		if(obj==null)return false;
		return true;
	}
	
	public int getMaxPos(long project_id) throws SQLException{
		Integer max=(Integer)this.sqlMapper.queryForObject("fdc_project_grah.getMaxPos",project_id);
		if(max==null){
			return 0;
		}
		return max+1;
	}
	
	
	public int count(long project_id) throws SQLException{
		return (Integer) this.sqlMapper.queryForObject("fdc_project_grah.size");
	}

	public List<FDCProjectGrah> getProjectGrahs(long project_id) throws SQLException{
		return (List<FDCProjectGrah>)this.sqlMapper.queryForList("fdc_project_grah.getProjectGrahs",project_id);
	}
	
	public List<FDCProjectGrah> getByType(String type) throws SQLException{
		return (List<FDCProjectGrah>)this.sqlMapper.queryForList("fdc_project_grah.getByType",type);
	}
	
	public FDCProjectGrah get(long id) throws SQLException{
		return (FDCProjectGrah)this.sqlMapper.queryForObject("fdc_project_grah.get",id);
	}

	public void update_status(long id,int status,int category) throws SQLException{
		Map<String,Long> keys=new HashMap<String,Long>();
		keys.put("id",id);
		keys.put("status",status+0l);
		keys.put("category",category+0l);
		this.sqlMapper.update("fdc_project_grah.update_status",keys);
	}
	
	public void delete(long id)throws SQLException{
		this.sqlMapper.delete("fdc_project_grah.delete",id);
	}
	
}
